package 集合0911.Collection;

import java.util.HashSet;
import java.util.Set;

public class set集合 {
    public static void main(String[]args){
        Set<Student>stus=new HashSet<>();
        Student s1=new Student("wang",23);
        Student s2=new Student("he",23);
        Student s3=new Student("gu",23);
        Student s4=new Student("zhou",23);
        stus.add(s1);
        stus.add(s2);
        stus.add(s3);
        stus.add(s4);
        for (Student s:stus){
            System.out.println(s);

        }
    }
}
class Student{
    private String name;
    private Integer age;

    public Student(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

